﻿using FCDB.Entity.ConfigEntity;
using FCDB.Entity;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace FCDB.Repository
{
    public  class ConfigHelper
    {
        private static string m_FormHeader = null;

        public static  string FormHeader {
            get
            {
                if (m_FormHeader == null)
                {
                    string EmailPath = Path.Combine(ConfigurationManager.AppSettings["HtmlTemplateFolder"], "formheader.html");
                    m_FormHeader = File.ReadAllText(EmailPath,Encoding.UTF8);
                }
                return m_FormHeader;
            }
        }
         

        private static IList<PayCompany> m_FinaceCompanyList=null;

        public static IList<PayCompany> FinaceCompanyList
        {
            get
            {
                m_FinaceCompanyList = LogicBase.DBHelper.PayCompany.ToList();
                return m_FinaceCompanyList;
            }
        }

        private static IList<CustomerServiceEntity> m_CustomerServiceList = null;

        public static IList<CustomerServiceEntity> CustomerServiceList
        {
            get
            {
                if (m_CustomerServiceList == null)
                {
                    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                    string XmlPath = ConfigurationManager.AppSettings["MeetingRoomImgFolder"];
                    string FilePath = Path.Combine(XmlPath, "CustomerService.xml");
                    doc.Load(FilePath);
                    XmlElement root = doc.DocumentElement;//跟元素
                    //RecursionNode(root);
                    System.Xml.XmlNodeList list = root.ChildNodes;  //跟元素下的子节点(列表)
                    IList<CustomerServiceEntity> List = new List<CustomerServiceEntity>();
                    foreach (XmlNode node1 in list)
                    {
                        XmlNodeList child = node1.ChildNodes;
                        CustomerServiceEntity i = new CustomerServiceEntity();
                        IList<string> str = new List<string>();
                        foreach (XmlNode node2 in child)
                        {
                            XmlNodeList child2 = node2.ChildNodes;
                            foreach (XmlNode node3 in child2)
                            {
                                str.Add(node3.Value);
                            }
                        }
                        i.CustomerServiceName = str[0];
                        i.Attendance = str[1];
                        i.AttendanceLoginName = str[2];
                        List.Add(i);
                    }
                    m_CustomerServiceList = List;
                }
                return m_CustomerServiceList;
            }
        }



   

        private static IList<string> m_StationeryDetial = null;

        public static IList<string> StationeryDetial
        {
            get
            {
                if (m_StationeryDetial == null)
                {
                    m_StationeryDetial = new List<string>();
                    string companyNamePath = Path.Combine(ConfigurationManager.AppSettings["MeetingRoomImgFolder"], "StationeryDetial.txt");
                    String[] strList = File.ReadAllLines(companyNamePath);
                    foreach (string item in strList)
                    {
                        m_StationeryDetial.Add(item.Trim());
                    }
                }
                return m_StationeryDetial;
            }
        }
    }
}
